package com.chuanghai.light.exceptionhandle;


import com.chuanghai.light.exceptionhandle.emum.CommonErrorEmum;

/**
 * 全局异常
 */
public class CommonException extends Exception implements CommonError{

    private CommonError commonError;

    //直接接收EmBussinessError的传参，，用于构建业务异常
    public CommonException(CommonErrorEmum commonError){
        super();
        this.commonError = commonError;
    }

    //自定义errormsg
    public CommonException(CommonError commonError){
        super();
        this.commonError = commonError;
        this.commonError.setErrorMsg("commonError");
    }

    @Override
    public String getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMsg() {
        return this.commonError.getErrorMsg();
    }

    @Override
    public CommonError setErrorMsg(String errMsg) {
        this.commonError.setErrorMsg(errMsg);
        return this;
    }
}
